package com.flower.domain.service.impl;

import cn.dev33.satoken.secure.SaSecureUtil;
import com.flower.auth.common.enums.AuthUserStatusEnum;
import com.flower.auth.common.enums.IsDeletedFlagEnum;
import com.flower.auth.infra.basic.entity.AuthPermission;
import com.flower.auth.infra.basic.entity.AuthUser;
import com.flower.auth.infra.basic.service.AuthPermissionService;
import com.flower.auth.infra.basic.service.AuthUserService;
import com.flower.domain.convert.AuthPermissionBOConverter;
import com.flower.domain.convert.AuthUserBOConverter;
import com.flower.domain.entity.AuthPermissionBO;
import com.flower.domain.entity.AuthUserBO;
import com.flower.domain.service.AuthPermissionDomainService;
import com.flower.domain.service.AuthUserDomainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-16 21:24
 */
@Service
public class AuthPermissionDomainServiceImpl implements AuthPermissionDomainService {

    @Resource
    private AuthPermissionService service;




    @Override
    public Boolean register(AuthPermissionBO authPermissionBO) {
        AuthPermission authPermission = AuthPermissionBOConverter.INSTANCE.convertBOToUser(authPermissionBO);
        authPermission.setIsDelete(IsDeletedFlagEnum.UN_DELETED.getCode());
        Integer result = service.insert(authPermission);

        return result > 0;

    }

    @Override
    public Boolean update(AuthPermissionBO authPermissionBO) {
        AuthPermission authPermission = AuthPermissionBOConverter.INSTANCE.convertBOToUser(authPermissionBO);
        Integer result = service.update(authPermission);
        return result > 0;
    }

    @Override
    public Boolean delete(AuthPermissionBO authPermissionBO) {
        AuthPermission authPermission = AuthPermissionBOConverter.INSTANCE.convertBOToUser(authPermissionBO);

        authPermission.setIsDelete(IsDeletedFlagEnum.DELETE.getCode());
        Integer result = service.update(authPermission);

        return result > 0;
    }
}
